/**
 * ShoppingCart 业务逻辑实现类
 * @author WangXinLei
 * @date 2014-09-10
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Order;
import com.chnbst.bstyun.model.vo.OrderVo;
import com.chnbst.bstyun.service.OrderService;

@Transactional
@Service
public class OrderServiceImpl  extends BaseService implements OrderService {

	//命名空间
	private final static String nameSpace = "com.chnbst.bstyun.mapper.OrderMapper";
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertOrder(Order order) {
		return DaoHelper.insert(nameSpace, "insertOrder", order);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateOrderByOrderId(Order order) {
		return DaoHelper.update(nameSpace, "updateOrderByOrderId", order);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectOrderByCondition(Map<String,Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectOrderByCondition", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Order selectOrderByGoodsId(Map<String, Object> map) {
		return (Order)DaoHelper.query(nameSpace, "selectOrderByGoodsId", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Order selectOrderByOrderId(Integer orderId) {
		return (Order)DaoHelper.query(nameSpace, "selectOrderByOrderId", orderId);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectOrderByUserId(Map<String, Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectOrderByUserId", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectOrderByConditions(Map<String, Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectOrderByConditions", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public OrderVo selectOrderVoByOrderId(Integer orderId) {
		return (OrderVo)DaoHelper.query(nameSpace, "selectOrderVoByOrderId", orderId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectOrderVoCountByConditions(Map<String, Object> map) {
		return DaoHelper.count(nameSpace, "selectOrderVoCountByConditions", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<Order> selectOrderByIsFree(Map<String, Object> map) {
		return (List<Order>)DaoHelper.list(nameSpace, "selectOrderByIsFree", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectDeleteOrderVoByMap(Map<String, Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectDeleteOrderVoByMap", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectDeleteOrderVoCountByMap(Map<String, Object> map) {
		return DaoHelper.count(nameSpace, "selectDeleteOrderVoCountByMap", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectMealsNumByCondition(Map<String, Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectMealsNumByCondition", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectLastOrdersByUserId(
			Map<String, Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectLastOrdersByUserId", map);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectOrderCount(Map<String, Object> map) {	
		return DaoHelper.count(nameSpace, "selectOrderCount", map);
	}
	
	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectAllOrders(Map<String, Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectAllOrders", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public OrderVo selectOrderDetailByOrderId(Integer orderId) {
		return (OrderVo)DaoHelper.query(nameSpace, "selectOrderDetailByOrderId", orderId);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<Order> selectOrdersByMap(Map<String, Object> map) {
		return (List<Order>)DaoHelper.list(nameSpace, "selectOrdersByMap", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> relationHasOrder(Map<String, Object> map) {
		return (List<OrderVo>) DaoHelper.list(nameSpace, "relationHasOrder", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> relationNewOrder(Map<String, Object> map) {
		return (List<OrderVo>) DaoHelper.list(nameSpace, "relationNewOrder", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<Order> selectOrderListByGoodsId(Map<String, Object> map) {
		return (List<Order>)DaoHelper.list(nameSpace, "selectOrderListByGoodsId", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Order selectOrderByContion(Map<String, Object> map) {
		return (Order)DaoHelper.query(nameSpace, "selectOrderByContion", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectTimeOutOrderVo(Map<String, Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectTimeOutOrderVo", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<OrderVo> selectExtendRenewOrderVo(Map<String, Object> map) {
		return (List<OrderVo>)DaoHelper.list(nameSpace, "selectExtendRenewOrderVo", map);
	}
	
}
